#include <GlobalData.h>
#include "EVector2.h"

template <typename TYPE>
Vector2<TYPE>::Vector2()
{
	//
}

template <typename TYPE>
Vector2<TYPE>::Vector2(TYPE x, TYPE y) :
	x(x),
	y(y)
{
	// empty
}

template <typename TYPE>
TYPE Vector2<TYPE>::dot(Vector2<TYPE> &other)
{
	return this->x * other.x + this->y * other.y;
}

template <typename TYPE>
Vector2<TYPE>& Vector2<TYPE>::normalize()
{
	TYPE lenght = x*x + y*y;

	x /= lenght;
	y /= lenght;

	return *this;
}

template <typename TYPE>
Vector2<TYPE> Vector2<TYPE>::getUnitX()
{
	return Vector2<TYPE>(1.0, 0.0);
}

template <typename TYPE>
Vector2<TYPE> Vector2<TYPE>::getUnitY()
{
	return Vector2<TYPE>(0.0, 1.0);
}

template <typename TYPE>
Vector2<TYPE> operator+(const Vector2<TYPE>& a, const Vector2<TYPE>& b)
{
	Vector2<TYPE> ret;
    ret.x = a.x + b.x;
    ret.y = a.y + b.y;
    return ret;
}

INSTANTIATE_VECTOR_TEMPLATE(Vector2);

template Vector2<float> 	operator+(const Vector2<float>&  a, const Vector2<float>&  b);
template Vector2<double> 	operator+(const Vector2<double>& a, const Vector2<double>& b);
template Vector2<int> 		operator+(const Vector2<int>&    a, const Vector2<int>&    b);

